%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/v4/simple-relations-tail-head"
    Bucket0("Bucket 0 (root)<br /><br />1: 60, 64, 68, 72<br />ᐳ: Access[8], Access[9], Object[10]<br />2: PgSelect[7], PgSelect[12]<br />ᐳ: 61, 65, 69, 73<br />3: PgSelectRows[15], PgSelectRows[16]"):::bucket
    Bucket1("Bucket 1 (listItem)<br />Deps: 61, 65<br /><br />ROOT __Item{1}ᐸ15ᐳ[17]<br />1: <br />ᐳ: 18, 21, 23, 25, 62, 63, 66, 67<br />2: PgSelectRows[32], PgSelectRows[44]<br />ᐳ: 31, 33, 43, 45"):::bucket
    Bucket2("Bucket 2 (listItem)<br />Deps: 69, 73<br /><br />ROOT __Item{2}ᐸ16ᐳ[19]<br />1: <br />ᐳ: 20, 22, 24, 26, 70, 71, 74, 75<br />2: PgSelectRows[39], PgSelectRows[49]<br />ᐳ: 38, 40, 48, 50"):::bucket
    Bucket3("Bucket 3 (nullableBoundary)<br />Deps: 33<br /><br />ROOT PgSelectSingle{1}ᐸpersonᐳ[33]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 40<br /><br />ROOT PgSelectSingle{2}ᐸpersonᐳ[40]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 45<br /><br />ROOT PgSelectSingle{1}ᐸpersonᐳ[45]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 50<br /><br />ROOT PgSelectSingle{2}ᐸcompound_keyᐳ[50]"):::bucket
    end
    Bucket0 --> Bucket1 & Bucket2
    Bucket1 --> Bucket3 & Bucket5
    Bucket2 --> Bucket4 & Bucket6

    %% plan dependencies
    PgSelect7[["PgSelect[7∈0] ➊<br />ᐸcompound_keyᐳ"]]:::plan
    Object10{{"Object[10∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    PgSelectInlineApply60["PgSelectInlineApply[60∈0] ➊"]:::plan
    PgSelectInlineApply64["PgSelectInlineApply[64∈0] ➊"]:::plan
    Object10 & PgSelectInlineApply60 & PgSelectInlineApply64 --> PgSelect7
    PgSelect12[["PgSelect[12∈0] ➊<br />ᐸforeign_keyᐳ"]]:::plan
    PgSelectInlineApply68["PgSelectInlineApply[68∈0] ➊"]:::plan
    PgSelectInlineApply72["PgSelectInlineApply[72∈0] ➊"]:::plan
    Object10 & PgSelectInlineApply68 & PgSelectInlineApply72 --> PgSelect12
    Access8{{"Access[8∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access9{{"Access[9∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access8 & Access9 --> Object10
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access8
    __Value2 --> Access9
    PgSelectRows15[["PgSelectRows[15∈0] ➊"]]:::plan
    PgSelect7 --> PgSelectRows15
    PgSelectRows16[["PgSelectRows[16∈0] ➊"]]:::plan
    PgSelect12 --> PgSelectRows16
    Access61{{"Access[61∈0] ➊<br />ᐸ7.m.joinDetailsFor27ᐳ"}}:::plan
    PgSelect7 --> Access61
    Access65{{"Access[65∈0] ➊<br />ᐸ7.m.joinDetailsFor41ᐳ"}}:::plan
    PgSelect7 --> Access65
    Access69{{"Access[69∈0] ➊<br />ᐸ12.m.joinDetailsFor34ᐳ"}}:::plan
    PgSelect12 --> Access69
    Access73{{"Access[73∈0] ➊<br />ᐸ12.m.joinDetailsFor46ᐳ"}}:::plan
    PgSelect12 --> Access73
    List62{{"List[62∈1]<br />ᐸ61,18ᐳ"}}:::plan
    PgSelectSingle18{{"PgSelectSingle[18∈1]<br />ᐸcompound_keyᐳ"}}:::plan
    Access61 & PgSelectSingle18 --> List62
    List66{{"List[66∈1]<br />ᐸ65,18ᐳ"}}:::plan
    Access65 & PgSelectSingle18 --> List66
    __Item17[/"__Item[17∈1]<br />ᐸ15ᐳ"\]:::itemplan
    PgSelectRows15 ==> __Item17
    __Item17 --> PgSelectSingle18
    PgClassExpression21{{"PgClassExpression[21∈1]<br />ᐸ__compound...rson_id_1”ᐳ"}}:::plan
    PgSelectSingle18 --> PgClassExpression21
    PgClassExpression23{{"PgClassExpression[23∈1]<br />ᐸ__compound...rson_id_2”ᐳ"}}:::plan
    PgClassExpression21 o--o PgClassExpression23
    PgClassExpression25{{"PgClassExpression[25∈1]<br />ᐸ__compound...__.”extra”ᐳ"}}:::plan
    PgClassExpression23 o--o PgClassExpression25
    First31{{"First[31∈1]"}}:::plan
    PgSelectRows32[["PgSelectRows[32∈1]"]]:::plan
    PgSelectRows32 --> First31
    Lambda63{{"Lambda[63∈1]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda63 --> PgSelectRows32
    PgSelectSingle33{{"PgSelectSingle[33∈1]<br />ᐸpersonᐳ"}}:::plan
    First31 --> PgSelectSingle33
    First43{{"First[43∈1]"}}:::plan
    PgSelectRows44[["PgSelectRows[44∈1]"]]:::plan
    PgSelectRows44 --> First43
    Lambda67{{"Lambda[67∈1]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda67 --> PgSelectRows44
    PgSelectSingle45{{"PgSelectSingle[45∈1]<br />ᐸpersonᐳ"}}:::plan
    First43 --> PgSelectSingle45
    List62 --> Lambda63
    List66 --> Lambda67
    List70{{"List[70∈2]<br />ᐸ69,20ᐳ"}}:::plan
    PgSelectSingle20{{"PgSelectSingle[20∈2]<br />ᐸforeign_keyᐳ"}}:::plan
    Access69 & PgSelectSingle20 --> List70
    List74{{"List[74∈2]<br />ᐸ73,20ᐳ"}}:::plan
    Access73 & PgSelectSingle20 --> List74
    __Item19[/"__Item[19∈2]<br />ᐸ16ᐳ"\]:::itemplan
    PgSelectRows16 ==> __Item19
    __Item19 --> PgSelectSingle20
    PgClassExpression22{{"PgClassExpression[22∈2]<br />ᐸ__foreign_...person_id”ᐳ"}}:::plan
    PgSelectSingle20 --> PgClassExpression22
    PgClassExpression24{{"PgClassExpression[24∈2]<br />ᐸ__foreign_...und_key_1”ᐳ"}}:::plan
    PgClassExpression22 o--o PgClassExpression24
    PgClassExpression26{{"PgClassExpression[26∈2]<br />ᐸ__foreign_...und_key_2”ᐳ"}}:::plan
    PgClassExpression24 o--o PgClassExpression26
    First38{{"First[38∈2]"}}:::plan
    PgSelectRows39[["PgSelectRows[39∈2]"]]:::plan
    PgSelectRows39 --> First38
    Lambda71{{"Lambda[71∈2]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda71 --> PgSelectRows39
    PgSelectSingle40{{"PgSelectSingle[40∈2]<br />ᐸpersonᐳ"}}:::plan
    First38 --> PgSelectSingle40
    First48{{"First[48∈2]"}}:::plan
    PgSelectRows49[["PgSelectRows[49∈2]"]]:::plan
    PgSelectRows49 --> First48
    Lambda75{{"Lambda[75∈2]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda75 --> PgSelectRows49
    PgSelectSingle50{{"PgSelectSingle[50∈2]<br />ᐸcompound_keyᐳ"}}:::plan
    First48 --> PgSelectSingle50
    List70 --> Lambda71
    List74 --> Lambda75
    PgClassExpression51{{"PgClassExpression[51∈3]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgSelectSingle33 --> PgClassExpression51
    PgClassExpression55{{"PgClassExpression[55∈3]<br />ᐸ__person__.”email”ᐳ"}}:::plan
    PgClassExpression51 o--o PgClassExpression55
    PgClassExpression52{{"PgClassExpression[52∈4]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgSelectSingle40 --> PgClassExpression52
    PgClassExpression56{{"PgClassExpression[56∈4]<br />ᐸ__person__.”email”ᐳ"}}:::plan
    PgClassExpression52 o--o PgClassExpression56
    PgClassExpression53{{"PgClassExpression[53∈5]<br />ᐸ__person__...full_name”ᐳ"}}:::plan
    PgSelectSingle45 --> PgClassExpression53
    PgClassExpression57{{"PgClassExpression[57∈5]<br />ᐸ__person__.”email”ᐳ"}}:::plan
    PgClassExpression53 o--o PgClassExpression57
    PgClassExpression54{{"PgClassExpression[54∈6]<br />ᐸ__compound...rson_id_1”ᐳ"}}:::plan
    PgSelectSingle50 --> PgClassExpression54
    PgClassExpression58{{"PgClassExpression[58∈6]<br />ᐸ__compound...rson_id_2”ᐳ"}}:::plan
    PgClassExpression54 o--o PgClassExpression58
    PgClassExpression59{{"PgClassExpression[59∈6]<br />ᐸ__compound...__.”extra”ᐳ"}}:::plan
    PgClassExpression58 o--o PgClassExpression59

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect7,Access8,Access9,Object10,PgSelect12,PgSelectRows15,PgSelectRows16,PgSelectInlineApply60,Access61,PgSelectInlineApply64,Access65,PgSelectInlineApply68,Access69,PgSelectInlineApply72,Access73 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,__Item17,PgSelectSingle18,PgClassExpression21,PgClassExpression23,PgClassExpression25,First31,PgSelectRows32,PgSelectSingle33,First43,PgSelectRows44,PgSelectSingle45,List62,Lambda63,List66,Lambda67 bucket1
    classDef bucket2 stroke:#7f007f
    class Bucket2,__Item19,PgSelectSingle20,PgClassExpression22,PgClassExpression24,PgClassExpression26,First38,PgSelectRows39,PgSelectSingle40,First48,PgSelectRows49,PgSelectSingle50,List70,Lambda71,List74,Lambda75 bucket2
    classDef bucket3 stroke:#ffa500
    class Bucket3,PgClassExpression51,PgClassExpression55 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgClassExpression52,PgClassExpression56 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression53,PgClassExpression57 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgClassExpression54,PgClassExpression58,PgClassExpression59 bucket6

